// 引入user集合
const MyShopCar = require("../../model/myShopCar");
const moment = require("moment-timezone");
module.exports = async(req, res) => {
    const {
        _id,
        uid,
        sid,
        count
    } = req.body;
    const resData = {
        data: req.body,
        meta: {
            code: 200,
            msg: "修改成功!",
        },
    };
    // 怎么在某个字段为空时就不更新
    let result = await MyShopCar.findOne({ _id }).updateOne({
        uid,
        sid,
        count,
        modify: moment().tz("Asia/Shanghai").format("YYYY/MM/DD HH:mm:ss"),
    });
    // 判断匹配数是1还是0,0证明对应用户不存在,1则证明对应用户存在,修改成功后返回修改之后的用户信息
    if (result.matchedCount) {
        resData.data = await MyShopCar.findOne({ _id });
        res.send(resData);
    } else {
        resData.meta.code = 400;
        resData.meta.msg = "修改失败";
        res.send(resData);
    }
};